 <template>
    <div class="index-page">
        <!-- 顶部按钮 -->
      <div class="but1">
          <router-link to="/home">
        <el-button type="warning" size="small" class="btn" style='margin-right: 5px;' icon="el-icon-menu">首页</el-button>
      </router-link>
        </div>
        <!-- 模糊搜索条件 -->
        <div class="search">
            <div class="search-item">
                <el-input placeholder="请输入老师名称" class="code-search" v-model="vkeyword"  @keyup.enter.native="search" icon="search"></el-input>
            </div>
            <el-button type="primary" class="add btn" size="small" style="border-radius:13px;" :loading="searchLoading" @click="search()" icon="el-icon-search"></el-button>
        </div>

        <!-- 数据表格展示区域 -->
         <el-table
    :data="dataList"
    border
    stripe
    size="small"
    style="width: 100%;text-align:center;">
   <el-table-column label="老师名称" width="100" align="center">
				<template scope="scope">
					<el-button size="small" type="text" style="color:#1F2D3D;text-decoration:underline;background: #BEDBDF; " @click="componentsShow('lsxq',scope)">{{scope.row.zwm}}</el-button>
				</template>
			</el-table-column>
    <el-table-column
    	align="center"
      prop="skzs"
      label="总课(次)"
      width="">
    </el-table-column>
    <el-table-column
    	align="center"
      prop="yjsks"
      label="已结算(次)"
      width="">
    </el-table-column>
    <el-table-column align="center" label="未结算" style="text-align: center;">
      <el-table-column
      	align="center"
        prop="zjcs1"
        label="主教(次)"
        width="">
      </el-table-column>
      <el-table-column
      	align="center"
        prop="zjcs2"
        label="+助教(次)"
        width="">
      </el-table-column>
      <el-table-column
      	align="center"
        prop="bkcs"
        label="+补课(次)"
        width="">
      </el-table-column>
      <el-table-column
      	align="center"
        prop="wjsks"
        label="=未结算课时"
        width="">
      </el-table-column>
       
      </el-table-column>
      <el-table-column
       	align="center"
        prop="zjjssj"
        label="最近结算日期"
        width="160">
      </el-table-column>
    </el-table-column>
    <!--<el-table-column
                label="操作"
                width="200px"
                align="center"
                fixed="right">
                <template scope="scope">
                    <el-button size="small" type="warning"   @click="componentsShow('edit',scope)">结算</el-button>
                    <el-button size="small" type="success"   @click="componentsShow('jsxq',scope)">结算记录</el-button>

                </template>

            </el-table-column>-->
            
  </el-table>

        <!-- 分页查询区域 -->
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="pageindex"
            :page-sizes="pagesizes"
            :page-size="pagesize"
            :layout="layout"
            :total="total"
            class="class-page">
        </el-pagination>


        <!-- 各个组件显示区域 -->

        <!-- 添加组件 -->
        <AddComponent v-if="portComponents.add.toggle"  @close="componentsHide"  :params="portComponents.add.params"></AddComponent>
        <!-- 编辑组件 -->
        <EditComponent v-if="portComponents.edit.toggle"  @close="componentsHide"  :params="portComponents.edit.params"></EditComponent>
        <!--权限组件-->
        <!-- <Authority v-if="portComponents.authority.toggle"  @close="componentsHide"  :data="portComponents.authority.data"></Authority>  -->

        <!-- 单独删除组件 -->
        <DeleteComponent v-if="portComponents.singleDelete.toggle"  @close="componentsHide"  :data="portComponents.singleDelete.data"></DeleteComponent>

        <LsxqComponent v-if="portComponents.lsxq.toggle" @close="componentsHide" :params="portComponents.lsxq.params"></LsxqComponent>

        <!-- 批量删除组件 -->
        <DeleteComponent v-if="portComponents.multipleDelete.toggle"  @close="componentsHide"  :data="portComponents.multipleDelete.data"></DeleteComponent>

        <JsxqComponent v-if="portComponents.jsxq.toggle" @close="componentsHide" :params="portComponents.jsxq.params"></JsxqComponent>

        <!-- 子路由显示区域 -->
        <router-view class="port-view"></router-view>
    </div>
</template>

<script>
    import { mapState } from 'vuex'
    import qs from 'qs'
    import AddComponent from './add'
    import LsxqComponent from '../personManage/lsxq'
    import JsxqComponent from './jsxq/list'
    import EditComponent from './edit'
    import DeleteComponent from './del'
    export default {
        components: {
            JsxqComponent,
            DeleteComponent,
            LsxqComponent,
            AddComponent,
            EditComponent
        },
        data () {
            return {
//              type: '',
                vkeyword: '',
                /*组件区域*/
                portComponents: {
                    singleDelete: {
                        type: 'singleDelete',
                        toggle: false,
                        params: '',
                        data: {
                            index: '',
                            type: 'single',
                            title: '此操作将删除该班级, 是否继续?'
                        }
                    },
                    multipleDelete: {
                        type: 'multipleDelete',
                        toggle: false,
                        params: '',
                        data: {
                            index: '',
                            type: 'multiple',
                            title: '此操作将删除您选中的班级, 是否继续?'
                        }
                    },
                    add: {
                        type: 'add',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    info: {
                        type: 'info',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    edit: {
                        type: 'edit',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                     jsxq: {
                        type: 'jsxq',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                    lsxq: {
                        type: 'lsxq',
                        toggle: false,
                        params: '',
                        data: {}
                    }
//                  authority: {
//                      type: 'authority',
//                      toggle: false,
//                      params: '',
//                      data: {}
//                  },
//                  forbidden: {
//                      type: ' forbidden',
//                      toggle: false,
//                      params: '',
//                      data: {}
//                  },
//                  authority: {
//                      type: 'authority',
//                      toggle: false,
//                      params: '',
//                      data: {}
//                  },
//                  reset: {
//                      type: 'reset',
//                      toggle: false,
//                      params: '',
//                      data: {}
//                  }
                },

                multipleDelNum:'', //获取批量选择的数据
                dataList: [],  //表格数据

                /*
                    prop :  接口参数名
                    label : 接口中文名
                    hide : 是否隐藏这一列   0是隐藏  1是显示
                    align : 这一列对齐顺序 ： left,right,center
                    headerAlign : 这一列表头对齐方式 ： left,right,center
                    formatter: function (row, column) {}
                */
                portTitleList: [



                    {
                        prop:'skzs',
                        label:'总课时',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'zjcs1',
                        label:'主教次数',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'zjcs2',
                        label:'助教次数',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'bkcs',
                        label:'补课次数',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },

                    {
                        prop:'wjsks',
                        label:'未结算课时',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                    {
                        prop:'yjsks',
                        label:'已结算课时',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },

                    {
                        prop:'jsrmc',
                        label:'结算人',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center'
                    },
                    {
                        prop:'zjjssj',
                        label:'最近结算日期',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'110',
                        headerAlign:'center'
                    },
                ],


                /*动画加载*/
                isLoading: false,//动画加载
                searchLoading: false,//搜索按钮触发按钮动画

                /*模糊搜索条件*/
                inputbjmc:'' , //  班级名称,


                /*分页属性设置*/
                layout: 'total, sizes, prev, pager, next, jumper',//组件布局
                pageindex: 1,//当前分页页码
                pagesizes: [12, 24, 36, 72],//显示个数的选择器选项
                pagesize: 12,//每页显示条目数
                total: 0,//总条数


                dropDownData:'', //
            }
        },
        created () {

            //加载页面时调用
            this.$store.dispatch('changeTitle','老师课时结算');//修改title
            this.$store.dispatch('changeRouterIndex', '/admin/teacherjs');//修改路由

            this.search();//分页获取默认数据
            // this.getdropDownData();//获取下拉框数据

        },//加载页面时
        methods: {
//      	tableRowClassName (row, index) {//隔行变色颜色设置
//              // console.log(row)
//              if ( index%4 == 0) {
//                  return "table-cell-red";
//              }else if( index%4 == 1 ){
//                  return "table-cell-yellow";
//              }else if( index%4 == 2 ){
//                  return "table-cell-green";
//              }else{
//                  return "table-cell-blue"
//              }
//          },
  cancelf () {
            //sonpage 关闭
          this.$store.dispatch('changeTitle','首页');//修改title
          // this.params.toggle = false;
//          this.$emit('close',{type:'time',cancel:true})
          },
            search () {//查询搜索触发事件
            	var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                  keyword: this.vkeyword,
                        yhid:logininfo.id,
                        xxid:logininfo.xxid,
                        pageindex: this.pageindex,
                        pagesize: this.pagesize
               })
             //执行
                 this.axios.post(this.$store.state.api + 'lsks/list',  params2 )
                 .then(res => {
//               console.log('qqqq',res)
                    let data = res.data.data;
                    let list = data.list;
                    this.total = data.totalPage;
                    this.dataList = list;
                    this.searchLoading = false;
                 }).catch(res => {
					 console.log(res)
                  this.searchLoading = false;
				})
            },
            handleSizeChange (val) {//每页显示条数触发事件
                this.pagesize = val;
                this.pageindex = 1;
                this.search();
            },

            handleCurrentChange (val) {//分页触发事件
                this.search();
            },
            checkSelect (selection, row) {//点击单选select触发事件
                console.log(selection, row)
                let strID = [];
                selection.forEach(function(v,i){
                    strID.push(v.id)
                })
                this.multipleDelNum = strID.join(",");
            },
            checkall (selection) {//点击全选select触发事件
                // console.log(selection)
                let strID = [];

                selection.forEach(function(v,i){
                    strID.push(v.id)
                })
                // console.log(strID.join(","))
                this.multipleDelNum = strID.join(",");
                // console.log(strID)
            },

            /* 组件的弹框  */
            componentsShow (type,data) { //显示组件
                console.log(type,data)
                for ( let i in this.portComponents ) {
                    if (type == this.portComponents[i].type) {

                        this.portComponents[i].toggle = true;
                        this.portComponents[i].params = data;

                        if (this.portComponents[i].data.type == 'single') {
                            this.portComponents[i].data.index = data.row.id

                        }else if(this.portComponents[i].data.type == 'multiple'){
                            this.portComponents[i].data.index = this.multipleDelNum;

                        }else if(this.portComponents[i].type == 'test'){
                            this.portComponents[i].data.distinction  = "test";

                        }else if(this.portComponents[i].type == 'score'){
                            this.portComponents[i].data.distinction  = "score";

                        }else{
                            return;
                        }
                        return;
                    }
                }

            },
            componentsHide (setting) { //关闭组件
                console.log(setting)
                for ( let i in this.portComponents ) {
                    if (setting.type == this.portComponents[i].type) {
                        this.portComponents[i].toggle = false;

                        if (!setting.cancel) {
                           this.search();
                        }
                        return;
                    }
                }
            }
        },
        computed: {
            multipleDeleteDisabled () {
                console.log(this.multipleDelNum)
                if (this.multipleDelNum) {
                    return false;
                }else{
                    return true
                }
            }
        }
    }
</script>

<style lang="less" scoped>
    .index-page {
        font-size:12px;
        position: relative;

        .btn {
            height: 30px;
            padding:0 10px;
            margin-left: 0;
        }
 .but1{
      width: 30%;
			height: 50px;
			float: left;
			line-height: 50px;
    }
    .search{
      width: 70%;
      height: 50px;
      line-height: 50px;
      float: right;
      text-align: right;
    }
        .classInfo:hover {
            color:#4094c7;
            cursor:pointer;
            text-decoration: underline;
        }

        .code-search {
            max-width: 130px;
            min-width: 100px;
            text-align: center;
            height: 50px;
            /*line-height: 50px;*/
            font-size: 12px;
        }

        .change-time{
            width: 480px;
            display: inline-block;
        }

        .class-page {
            text-align: left;
            margin-top:10px;
        }

        .search-item {
            display: inline-block;
        }

        h2{
            line-height: 40px;
        }

    }
</style>
